/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package practice;
import java.util.Arrays;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import java.io.IOException;
import static chanlib.Chan_IO.*;

/**
 * @author robit
 */
public class MakeItSmooth{
    /*
      All neccesary to be defined
      including:
      variable, inner class
    */
    // static int A;
    // static void B();
    // static class C
    public static int D,I,M,N;
    public static int a[];
    public static int cost[][];
    // allow for an insertion at the end

    /*
       One calculation fits all of the cases.
    */
    static void preReckon(){
        return;
    }

    /*
      calculate the answer
    */
    private static void reckon(int line) {
        D=Int();I=Int();M=Int();N=Int();
        a=new int[N];
        for(int i=0;i<N;i++){
            a[i]=Int();
        }
       
        cost=new int[N+1][256];
        for(int n=1;n<=N;n++){
            for(int p=0;p<256;p++){
                // Deletion
                cost[n][p]=cost[n-1][p]+D;
                // Change to p
                for(int q=0;q<256;q++){                    
                    if(Math.abs(q-p)<=M){
                        cost[n][p]=Math.min(cost[n-1][q]+Math.abs(p-a[n-1]), cost[n][p]);
                    } 
                }
            }
            if(M!=0)
            for(int p=0;p<256;p++){
                // Insertion
                for(int r=0;r<256;r++){
                    cost[n][p]=Math.min(cost[n][r]+(Math.abs(r-p)+M-1)/M*I, cost[n][p]);
                }
            }
        }

        int minc=D*N;
        for(int p=0;p<256;p++)
         minc=min(minc,cost[N][p]);

        String ans = ""+minc;
        String output=String.format("Case #%d: %s",line,ans);
        writeln(output, OUTFILE);
        //writeln(String.format("D=%d I=%d M=%d N=%d\n%s", D, I, M, N, ans),ANALFILE);
        println(""+line);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        /*
           Pre-computing for all cases
        */

        // Just in case!
        //preReckon();
        //while((char)read()!='P');

        /*
          Input-output
        */
        boolean test=false;
        boolean small=false;
        String prob="B";
        String filename;
        if(test) filename="test";
        else{
            if(small) filename=prob+"-small-practice";
            else filename=prob+"-large-practice";
        }
        try {
            /*
               Init IO,plus determination of input line number
             */
            int lineNums = initFileIO(filename);
            for (int i = 1; i <= lineNums; i++) {
                reckon(i);
            }
        } finally {
            endIO();
        }
    }

}
